<template>
	<div class="zhengtuojianhuo">
		<van-nav-bar :fixed="true" class="navBar" title="库内移动" left-arrow @click-left="$router.go(-1)"></van-nav-bar>




		<div class="goodsFromWarp">
				<div class="goodsInputWarp">
						<div class="goodsInputLabel" style="width: 60px;" >
							<div class="goodsInputBorder"></div>
							<div class="skuName"  >移出：</div>
						</div>
						<van-field

							 class="skuInput"
							 v-model="editForm.jhrqid"
							 placeholder="请填写移出容器"
							 clearable
							 @keyup="onEnter($event,do_inputspbar)"
						 />

						 <div class="searchBtn">
								<button :disabled="isdisabled"  @click.stop="lingquBtn()" >
									<van-icon name="ellipsis" color="#1989fa"  />
								</button>
						 </div>
				</div>


				<div class="goodsInputWarp" >
						<div class="goodsInputLabel" style="width: 60px;" >
							<div class="goodsInputBorder"></div>
							<div class="skuName">目标：</div>
						</div>
						<van-field
							 class="skuInput"
							 v-model="editForm.cwnot"
							 placeholder="请填写目标容器"
							 clearable
							 @keyup="onEnter($event,do_inputspbarMubiao)"
						 />

						 <div class="searchBtn">
								<!-- <button :disabled="isdisabled"  @click.stop="lingquBtn()" >
									<van-icon name="ellipsis" color="#1989fa"  />
								</button> -->
						 </div>
				</div>
		</div>


		<div class="skuBtn">
			<van-button type="info" :disabled="isdisabled" @click="lingquBtn()">领取任务</van-button>
			<van-button type="info" :disabled="isdisabled" @click="saveGoodsBtn()">移位</van-button>
		</div>


		<div class="carCardWarp">
			<div class="carCard" v-for="(item,index) in lingquData" :key="index">

				<div class="goodsTitleRow" style="margin-bottom: 10px;">
						<div class="goodsTitleLabel">
							<div class="skuName">商品：</div>
						</div>
						<div class="skuNoTitle">
						{{item.itemid}}-{{item.subsname}}
						</div>
				</div>


				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>仓位:</span>{{item.cwno}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>箱装:</span>{{item.unit}}</van-col>
				  <van-col span="12"> <span>箱数:</span>{{item.pack}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="12"> <span>散数:</span>{{item.qty}}</van-col>
				  <van-col span="12"> <span>总数:</span>{{item.totqty}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="24"> <span>已分配数:</span>{{item.yfpqty}}</van-col>
				</van-row>

				<van-row class="goodRow" style="margin-top: 10px;">
				  <van-col span="24"> <span>生产日期:</span>{{item.p_date}}</van-col>
				</van-row>

			</div>
		</div>


	</div>
</template>

<script>

export default {
  name: 'kuneiyidong',
  data() {
    return {
			editForm:{
				jhrqid:'',
				cwnot:'',
				hztotqty:'',
			},
			isdisabled:false,
			lingquData:[
				{
					itemid:'',
					subsname:'',
					p_date:'',
				}
			],
			isLingQuVisible:false,
			skuData:[],
			isSkuVisible:false,
			index:0,
			skuRow:{},
			timeoutId: null,
			isMessageVisible:false,
			total:0,
			areElementsSame:''
		};
  },
	computed: {
		 ryuser: function(){
			 return this.GWO(true).gUSER;
		 },
	},
  methods: {
		do_inputspbar(pmtxt){
			console.log(pmtxt)  //扫描枪获取的参数
			this.editForm.jhrqid = pmtxt
			this.lingquBtn()
		},
		lingquBtn(){
			var _self = this;
			_self.total = 0
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_pandian',
				'i':this.FNULLE([
				'opmode','Y_KNYD_qrybill',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				'jhrqid',this.editForm.jhrqid,
				])
				},'库内移动查询',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到库内移动查询")
					console.log(rtn_json_obj)
					_self.lingquData = rtn_json_obj
					_self.editForm.hztotqty = rtn_json_obj[0].hztotqty
				}
			});
		},
		do_inputspbarMubiao(pmtxt){
			console.log(pmtxt)  //扫描枪获取的参数
			this.editForm.cwnot = pmtxt
			this.saveGoodsBtn()
		},
		saveGoodsBtn(){
			if(this.editForm.jhrqid >''){
				// 请确从仓位:" + jhrqid (移出仓位输入框)+" 到仓位:"+cwnot (目标仓位输入框)+ "\n" + "\n整托盘移动,是否继续?
				this.$dialog.confirm({
				  title: '提示',
				  message:'请确从仓位:' + this.editForm.jhrqid + '到仓位:' + this.editForm.cwnot + '整托盘移动,是否继续?',
				}).then(() => {
					this._getYiDong()
				}).catch(() => {

				});
			}else{
				this.$toast.fail('请先选择要移动的位置')
			}
		},
		_getYiDong(){
			var _self = this;
			_self.total = 0
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_pandian',
				'i':this.FNULLE([
				'opmode','Y_KNYD_qrcwno',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				'jhrqid',this.editForm.jhrqid,
				'cwnot',this.editForm.cwnot,
				'hztotqty',this.editForm.hztotqty,
				])
				},'校验拣货容器',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到校验拣货容器")
					console.log(rtn_json_obj)
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						return
					}else{
						_self.$toast.fail(rtn_json_obj[0].ret_mess)
						_self.lingquData = []
					}
				}
			});
		}
  },
  mounted() {

  },
	components: {

	},
};
</script>

<style lang="scss" scoped>
	// 引入公共样式
	@import '@/assets/css/base.scss';
	@import '@/assets/css/input.scss';
	div.zhengtuojianhuo{
		padding-top: 50px;
	}



	div.carCardWarp{
		width: 94%;
		margin-left: 3%;
		margin-right: 3%;
		margin-top: 20px;
		font-size: 14px;
		div.carCard{
			position: relative;
			border-left: 5px solid #4998FF;
			box-sizing: border-box;
			padding-left: 10px;
			padding-right: 10px;
			border-radius:5px;
			background-color: #fff;
			padding-top: 10px;
			padding-bottom: 10px;
			margin-bottom:15px;
			div.status{
				position: absolute;
				right: 0;
				top: 0;
				width: 65px;
				height: 30px;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
				font-size: 12px;
				border-radius: 0px 10px 0px 10px;
			}
			div.goodRow{
				margin-bottom:8px;
				font-size: 20px;
				font-weight: bold;
				span{
					display: inline-block;
					width:100px;
				}
			}
			div.goodsTitleRow{
				display: flex;
				width: 100%;
				font-size: 20px;
				font-weight: bold;
				div.goodsTitleLabel{
					width: 80px;
				}
				div.skuNoTitle{
					width: calc(100% - 80px);
				}
			}
		}
	}
</style>
